home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / compguid / doctemp / docdev / makedoc.sx < prev   
Encoding:
Text File  |  1996-05-21  |  6.9 KB  |  240 lines  |  [TEXT/ttxt]

  1. --<<<-
  2. -- Filename:MakeDoc.sx
  3.  
  4. -- Other Files Required:
  5. --        DocFns.sx, which provides functions for creating a document.
  6. --        DocFns.sx is filed in automatically.
  7.  
  8. -- Purpose:
  9. --        MakeDoc.sx was used to create the title container "seadoc.sxt".
  10. --        This file provides functions for importing media and 
  11. --         creating objects that provide data for a sample Document, 
  12. --        then saves the media and data objects to the object store.
  13.  
  14.  
  15. -- Specialized Classes: 
  16. --        GlossaryData and MovieData.
  17. --         GlossaryData instances hold heading, description and 
  18. --         picture for a page
  19. --         MovieData instances hold heading, description 
  20. --        movie, and copyright info for a page
  21.  
  22. -- Instructions to User:
  23. --        You don't need to load this file; 
  24. --        It just shows you how "seadoc.sxt" was created.    
  25. --        If you want to create seadoc.sxt from scratch, 
  26. --         you can load this file
  27.     
  28.  
  29. -- Author:
  30. --        Jocelyn Becker
  31. --         Modified on: 11/13/95 to update to 1.5
  32.  
  33.  
  34. ------------------------------------------------------------------------
  35. -- Create the classes to act as data objects for the pages in a document
  36.  
  37. fileIn theScriptDir name:"docfns.sx"
  38.  
  39. print "filed in docfns.sx"
  40.  
  41. class GlossaryData (RootObject)
  42.     instance variables
  43.         heading 
  44.         description 
  45.         picture
  46.         copyrightInfo:(new string)
  47.     end
  48.     
  49.  
  50. class MovieData (RootObject)
  51.     instance variables
  52.         heading 
  53.         description 
  54.         movie
  55.         copyrightInfo:(new string)
  56.         music
  57.     end
  58.     
  59. -- create a variable to point to the media subdirectory
  60.  
  61. global theMediaDir := spawn theScriptDir "Media"
  62.     
  63.  
  64. -- Create the database to be displayed by the document.
  65. -- In this case its a dictionary of whale-related words.
  66. -- This functions creates objects that hold a heading, description and picture.
  67. function makeWhaleGlossaryInstances -> 
  68. (
  69.     local glossary := new array
  70.     local glossaryWord
  71.     
  72.     glossaryWord := new GlossaryData
  73.     glossaryWord.Heading := "Fluking" as Text
  74.     glossaryWord.Description := ("As the whale goes down for a dive, it slaps
  75. the surface of the water with its fluke (tail)." As Text)
  76.     glossaryWord.picture := importMedia theimportexportengine \
  77.         (getstream theMediaDir "fluke.pic" @readable) \
  78.         @image @pict @bitmap
  79.         
  80.     append glossary glossaryWord
  81.     
  82.     glossaryWord := new GlossaryData
  83.     glossaryWord.Heading := "Breaching" as Text
  84.     glossaryWord.Description := ("The whale jumps clear out of the water in
  85. one huge thrust." as Text)
  86.     glossaryWord.picture := importMedia theimportexportengine \
  87.         (getstream theMediaDir "breach.pic" @readable) \
  88.         @image @pict @bitmap
  89.         
  90.     append glossary glossaryWord
  91.         
  92.     glossaryWord := new GlossaryData
  93.     glossaryWord.Heading := "Blowing" as Text
  94.     glossaryWord.Description := ("When the whale breathes at the surface,
  95. its breath turns into a plume of steam." as Text)
  96.     glossaryWord.picture := importMedia theimportexportengine \
  97.         (getstream theMediaDir "blow.pic" @readable) \
  98.         @image @pict @bitmap
  99.         
  100.     append glossary glossaryWord
  101.         
  102.     glossaryWord := new GlossaryData
  103.     glossaryWord.Heading := "Spyhopping" as Text
  104.     glossaryWord.Description := ("The whale lifts its head out of the water to
  105. look around for a few seconds." as Text)
  106.     glossaryWord.picture := importMedia theimportexportengine \
  107.         (getstream theMediaDir "spyhop.pic" @readable) \
  108.         @image @pict @bitmap
  109.         
  110.     append glossary glossaryWord
  111.         
  112.     print "glossary made"
  113.     return glossary
  114. )
  115.  
  116. -- Create more of the database to be displayed by the document.
  117. -- This functions creates objects that hold a heading, description and movie.
  118. -- tc is the title container to which to save the imported media
  119. function makeMovieDataInstances tc ->    
  120. (
  121.     local movieList := new array
  122.     local tempmovie
  123.     local videoStream
  124.     
  125.     
  126.     
  127.     local movie := new MovieData
  128.         movie.Heading := "Humpback Whales" as Text
  129.         movie.description:= ("Humpback whales have baleen instead of
  130. teeth." as Text)
  131.         videoStream := getstream theMediaDir "whale.mov" @readable
  132.         tempmovie := importMedia theImportExportEngine videoStream \
  133.             @movie @quicktime @interleavedMoviePlayer container: tc    
  134.         movie.movie := tempmovie
  135.         movie.music := importMedia theImportExportEngine \
  136.             (getStream theMediaDir "whale.aif" @readable) \
  137.             @sound @aiff @player container:tc
  138.         movie.music.masterclock := movie.movie
  139.         
  140.     
  141.     append movieList movie
  142.             
  143.     movie := new MovieData
  144.         movie.Heading := "Giant Octopii" as Text
  145.         movie.description :=("A giant octopus is a fearsome site for hapless
  146. scuba divers." as Text)
  147.         videoStream := getstream theMediaDir "octo.mov" @readable
  148.         tempmovie := importMedia theImportExportEngine videoStream \
  149.             @movie @quicktime @interleavedMoviePlayer container: tc    
  150.         movie.movie := tempmovie
  151.         movie.copyRightInfo := "Music copyright by ArisMedia"
  152.         movie.music := importMedia theImportExportEngine \
  153.             (getStream theMediaDir "octo.aif" @readable) \
  154.             @sound @aiff @player container:tc
  155.         movie.music.masterclock := movie.movie
  156.     
  157.     append movieList movie
  158.     
  159.     movie := new MovieData
  160.         movie.Heading := "Schooling Fish" as Text
  161.         movie.description := ("Thousands of schooling fish glitter in the
  162. rays of light that pierce the ocean." as Text)
  163.         videoStream := getstream theMediaDir "fish.mov" @readable
  164.         tempmovie := importMedia theImportExportEngine videoStream \
  165.             @movie @quicktime @interleavedMoviePlayer container: tc
  166.         movie.movie := tempmovie
  167.         movie.copyRightInfo := "Music copyright by ArisMedia"
  168.         movie.music := importMedia theImportExportEngine \
  169.             (getStream theMediaDir "fish.aif" @readable) \
  170.             @sound @aiff @player container:tc
  171.         movie.music.masterclock := movie.movie
  172.     
  173.     append movieList movie
  174.         
  175.     print "movie list made "
  176.     return movieList
  177. )
  178.  
  179. -- These are global so we can check that importing was successful
  180. -- and also save the lists to the title container
  181. global movieList, glossaryList
  182.  
  183. -- This is a cover function to import the bitmaps and movies 
  184. -- and create the database
  185. -- tc is the title container to which to save the imported media
  186. function doImporting tc -> 
  187. (
  188.      movieList := makeMovieDataInstances (tc)
  189.      glossaryList := makeWhaleGlossaryInstances ()
  190. )
  191.  
  192.  
  193. -- This function creates a document to display the ocean data
  194. function createDoc1 glossaryList movieList pageWidth pageHeight ->
  195. (
  196.     local doc := makeDocument \
  197.         pageWidth pageHeight \
  198.         glossaryList movieList
  199.     
  200.     local docWindow := new window \
  201.             boundary: (new rect x2: (pageWidth + 20)  \
  202.                                 y2: (pageHeight + 20) ) \
  203.             fill: whitebrush 
  204.     
  205.     docWindow.x := 25
  206.     docWindow.y := 45
  207.     doc.x := 10
  208.     doc.y := 10
  209.     
  210.     append docWindow doc
  211.     show docWindow
  212.     goTo doc 1    
  213.     return doc
  214. )
  215.         
  216. -- Create a title container to hold the media
  217.  
  218. global tc := new titlecontainer dir:theScriptDir path:"seadoc.sxt" \
  219.     name: "The Sea"
  220.  
  221. -- Import the media
  222. print "Now importing the media. Please stay on the line."
  223. doimporting tc
  224.  
  225. -- create the document
  226. -- save the document's window to the title container
  227. global doc1 := createdoc1 glossaryList movieList 320 400
  228. goto doc1 1
  229. append tc doc1.presentedBy
  230.  
  231. -- append the functions used by the movie buttons
  232. append tc playmovie
  233. append tc stopmovie
  234.  
  235. tc.startUpAction := (tc -> foreach tc load undefined)
  236.     
  237. -- Close the title 
  238.  close tc    
  239.  
  240.